﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;

namespace NHTools.Tools
{
    public class Provider
    {
        //public static ISessionFactory SessionFactory = CreateSessionFactory();
        public static Logger logger = LogManager.GetCurrentClassLogger();

        public static void CreateDB()
        {
            //FluentConfigurator.SetConfig();
            
            new NHibernate.Tool.hbm2ddl.SchemaExport(FluentConfigurator.NHConfiguration).Drop(true, true);
            new NHibernate.Tool.hbm2ddl.SchemaExport(FluentConfigurator.NHConfiguration).Create(true, true);
        }

        public static string ConnectionString { get; set; }


        //private static ISessionFactory CreateSessionFactory()
        //{
        //    _Configuration = Fluently.Configure()
        //        .Database(MsSqlConfiguration.MsSql2005
        //                      .ConnectionString(
        //                      c => c.Is(ConfigurationManager.AppSettings["ConStr"])))
        //        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Provider>())//.ExportTo(@"E:\kaProjeTfs\AdimAdimDavaKaydi.root\AdimAdimDavaKaydi-NHibernate-Branch\Test\bin\Debug\Maps"))
        //        .BuildConfiguration().SetInterceptor(new BuklaInterceptor());
        //    SessionFactory = null;

        //    //NHibernate.Cfg.Configuration _Configuration = new NHibernate.Cfg.Configuration();
        //    //_Configuration.SetDefaultAssembly("AvukatProNHBase")
        //    //    .SetDefaultNamespace("AvukatProNHBase.Entities")
        //    //    .AddDirectory(new DirectoryInfo(Application.StartupPath + "\\Maps")).SetInterceptor(new AVPInterceptor());

        //    return _Configuration.BuildSessionFactory();
        //}
    }
}
